WebApplicationContentxt wac;

//事件监听
@Async
@EventListener(classes = MyEvent.class)
public void handler(MyEvent event) {
    try {
        do something...
    } catch(Exception e) {
        log.error("");
    }
}

//事件发送
public void function() {
    wac.publishEvent(new MyEvent());
}